<template>
  <el-container>
    <el-header class="home-header">
      <div>管理系统</div>
      <el-button type="primary" @click="singleOut">退出</el-button>
    </el-header>

    <el-container>
      <el-aside :width="collapseWidth + 'px'">
        <div class="open" @click="openMenu">点击</div>
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          background-color="#333744"
          text-color="#fff"
          active-text-color="#409EFF"
          :collapse="collapse"
          :collapse-transition="false"
          router
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>导航一</span>
            </template>
            <el-menu-item index="welcome">选项1</el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>用户</span>
            </template>
            <el-menu-item index="user1">用户列表1</el-menu-item>
            <el-menu-item index="user2">用户列表2</el-menu-item>
          </el-submenu>
          <!-- <el-menu-item index="2">
            <i class="el-icon-menu"></i>
            <span slot="title">导航二</span>
          </el-menu-item>
          <el-menu-item index="3" disabled>
            <i class="el-icon-document"></i>
            <span slot="title">导航三</span>
          </el-menu-item>
          <el-menu-item index="4">
            <i class="el-icon-setting"></i>
            <span slot="title">导航四</span>
          </el-menu-item> -->
        </el-menu>
      </el-aside>

      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      collapse: false,
      collapseWidth: '200'
    }
  },
  methods: {
    handleOpen(e) {
      console.log(e, 'e')
    },
    handleClose() {},
    openMenu() {
      this.collapse = !this.collapse
      if (this.collapse) {
        this.collapseWidth = '64'
      } else {
        this.collapseWidth = '200'
      }
    },
    singleOut() {
      this.$router.replace('/login')
    }
  }
}
</script>

<style lang="less" scoped>
.el-container {
  height: 100%;

  .open {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    background-color: #4a5064;
  }

  .home-header {
    background-color: #373d41;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 100px;
    box-sizing: border-box;
  }

  .el-menu {
    border-right: none;
  }

  .el-aside {
    background-color: #333744;
  }

  .el-main {
    background-color: #eaedf1;
  }
}
</style>
